app.controller('OrganizationModalCtrl', function ($scope, $modalInstance, toaster, param) {

	$scope.param = param;
	if ($scope.param.data == null) $scope.param.data = {};

	$scope.dplist = [];
	$scope.ms = $scope.param.ms;

	//模块下拉列表
	$scope.loaddplist = function () {
		for (var i = 0; i < $scope.ms.length; i++) {
			if ($scope.ms[i] == 2) {
				$scope.dplist.push({ id: 2, name: "城际约租" });
			} else if ($scope.ms[i] == 3) {
				$scope.dplist.push({ id: 3, name: "跨城巴士" });
			}
		}

		if ($scope.param.data.moduleId != null) {
			for (i = 0; i < $scope.dplist.length; i++) {
				if ($scope.param.data.moduleId == 2 && $scope.dplist[i].name == "城际约租") {
					$scope.dplist.selected = $scope.dplist[i];
				} else if ($scope.param.data.moduleId == 3 && $scope.dplist[i].name == "跨城巴士") {
					$scope.dplist.selected = $scope.dplist[i];
				}
			}
		} else {
			$scope.dplist.selected = $scope.dplist[0];
		}
	};
	$scope.loaddplist();

	$scope.ok = function () {
		if ($scope.myForm.$valid) {
			$scope.param.data.moduleId = $scope.dplist.selected.id;
			$modalInstance.close($scope.param);
		}
	};

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
	};
});